// pages/cp_detail/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info:null,
    likeClass:'normal'
  },

  scClick:function(){
    var that = this;
    var info = that.data.info;
    var isSC = info.isSC;
    info.isSC = !isSC;
    if(info.isSC){
      that.setData({
        likeClass:'active'
      })
    }else{
      that.setData({
        likeClass:'normal'
      })
    }
    that.setData({
      info:info
    })
    wx.setStorageSync('curCP',info);
    var cpList = app.globalData.cpList;
    for(let  i = 0; i < cpList.length; i++){
      let item = cpList[i];
      if(item.cpName == info.cpName){
        item.isSC = info.isSC
        break;
      }
    }
    wx.setStorageSync('cpList', cpList)
    app.globalData.cpList = cpList;
    console.log(app.globalData.cpList)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var info = wx.getStorageSync('curCP');
    console.log(info)
    this.setData({
      info:info
    })
    if(info.isSC){
      that.setData({
        likeClass:'active'
      })
    }else{
      that.setData({
        likeClass:'normal'
      })
    }
    wx.setNavigationBarTitle({
      title: info.cpName,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})